package com.zoe.study;

import com.zoe.study.config.MyConfig;
import com.zoe.study.entity.Book;
import com.zoe.study.entity.Cat;
import com.zoe.study.util.HelloUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author Zoe.Zhang
 * @Date: 2021/09/12
 * @Description
 */
@RestController
@SpringBootApplication
public class MainAppHelloWord {

    @Autowired
    ApplicationContext applicationContext;

    @GetMapping("/")
    public String hello() {
        // 被@Configuration注解修饰,获取到的是代理对象
        System.out.println(applicationContext.getBean(MyConfig.class));
        // 被Bean注解修饰,获取到的是对象本身
        System.out.println(applicationContext.getBean(Cat.class));
        // 被Component注解修饰,获取到的是对象本身
        System.out.println(applicationContext.getBean(Book.class));
        return HelloUtil.hello();
    }

    public static void main(String[] args) {
        SpringApplication.run(MainAppHelloWord.class, args);
    }
}
